-
Notifications
You must be signed in to change notification settings - Fork 444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Begin enabling pre-commit hooks #2242
Conversation
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
/remove-lifecycle stale |
@droctothorpe Hey Alex! Sorry for the late response. I'm starting to review this PR. Are you still here? |
No worries! Happy to rebase and re-run if it's worth merging. |
Thank you! |
00d9930
to
fa0552a
Compare
Bump cc @andreyvelich |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding this and sorry for the late review @droctothorpe!
I left a few comments.
@@ -1,6 +1,5 @@ | |||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! | |||
import grpc | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we exclude files that auto-generated ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's okay to modify them, but am happy to update the pre-commit file if excluding them is preferable. There are quite a few files that fall into this category (assuming there aren't more that don't include the DO NOT EDIT
warning:
❯ grep -r "DO NOT EDIT" . | wc -l
110
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like pre-commit doesn't let you exclude files based on content, just a regex for the filename, but the generated files have names that truly run the gamut. Given that these specific modifications are superficial and will be overwritten when the files are regenerated anyway, do you mind if we keep them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be problematic, since we run make generate
command to make sure user runs this script before making any API changes.
Can't we use exclude
parameter ?
https://pre-commit.com/#top_level-exclude
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are doing it here: https://github.com/kubeflow/katib/blob/master/.github/workflows/test-go.yaml#L34
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, I can see that KFP does it: https://github.com/kubeflow/pipelines/blob/master/.pre-commit-config.yaml#L48
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @andreyvelich! Any objection to following KFP's example and just listing the full paths? With 113 unique generated files, it's going to take forever to generate the 30 or so regexes that will be required to cover them all and will arguably reduce readability (regex is a write-only language 😂 ).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess, we don't need to list all 113 unique files, just find common patterns.
E.g.
exclude: (/pkg/client/|/pkg/mock/|/pkg/apis/manager|*zz_generated.deepcopy.go|sdk/python/v1beta1/kubeflow/katib/models/)
WDYT @droctothorpe ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely, right! Sorry, I was being lazy. Fix incoming.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Also squashed and removed all the generated files, then validated that it's excluding correctly by running pre-commit run --all-files
and confirming that none of the generated files get modified.
Thanks for the review, @andreyvelich! |
Sorry for the late reply @droctothorpe! |
Will address ASAP. Thanks, @andreyvelich. |
34e5411
to
3ad430f
Compare
Signed-off-by: droctothorpe <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for updating this @droctothorpe!
Just a few small comments from me.
Please can you update the developer guide to explain how to install and run pre-commit
.
Maybe we could add similar section as for Training Operator code style: https://github.com/kubeflow/training-operator/blob/master/docs/development/developer_guide.md#code-style
Signed-off-by: droctothorpe <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this great contribution @droctothorpe!
If you have some bandwidth it would be great to add the same for Training Operator.
/lgtm
/assign @johnugeorge @tenzen-y
Happy to set this up for the training operator as well and plan to submit follow up PRs to both repos to enable additional hooks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, we should be ready to merge this.
@droctothorpe Please can you create tracking issue to enable pre-commit for Training Operator ?
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andreyvelich The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
* Begin enabling pre-commit hooks Signed-off-by: droctothorpe <[email protected]> * Address PR feedback Signed-off-by: droctothorpe <[email protected]> --------- Signed-off-by: droctothorpe <[email protected]>
What this PR does / why we need it:
This PR implements some basic pre-commit hooks and applies them retroactively to the entire codebase. All of the changes in this PR, other than the addition of
.pre-commit-config.yaml
, were automatically generated by the isort pre-commit hook. This pre-commit configuration is based off of Kubeflow Pipeline's to promote consistent code across the various Kubeflow repositories. The only difference is that I commented out the majority of the hooks, because if we tried to implement all of them simultaneously, the resulting PR would be enormous in size. This PR is a kind of proof of concept. If merged, I'll just progressively uncomment and enable the other pre-commit hooks (either sequentially or all once depending on preference) and execute them retroactively and submit one or more follow up PRs.Not sure how to integrate it into katib's CI if anyone has any input on that. Highly recommend doing so. It's the only way to enforce the standards that pre-commit enables.
Which issue(s) this PR fixes
Fixes # #2187
Checklist: